import { sysLogin } from '@/api/login.js'
import { Message } from 'element-ui'
import { getItem, setItem } from '@/utils/auth.js'
const state = {
  token: getItem() || ''
}
const getters = {}
const mutations = {
  setToken (state, value) {
    // 储存token
    setItem(value)
    state.token = value
  }
}
const actions = {
  async toLogin (store, value) {
    const res = await sysLogin(value)
    console.log('登录信息', res)
    store.commit('setToken', res.data)
    Message.success(res.message)
  }
}
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
